<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<base href="<?php echo $this->config->config['base_url'] ?>" />
<title><?=$title?></title>
<!-- ext -->		
	<link rel="stylesheet" type="text/css" href="resources/js/ext/2.2/resources/css/ext-all.css"/>
	<link rel="stylesheet" type="text/css" href="resources/css/skins/xtheme-silvercherry.css" />

	<script type="text/javascript" src="resources/js/ext/2.2/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="resources/js/ext/2.2/ext-all.js"></script>	
	<script type="text/javascript" src="resources/js/ext-used-features/miframe-min.js"></script>
	<script type="text/javascript">
      Ext.onReady(function() { 
 		//default ext s.gif
		Ext.BLANK_IMAGE_URL = 'resources/js/ext/2.2/resources/images/default/s.gif';
      });		
	
	</script>			
<!-- custom css-->
	
<style type="text/css">
.x-panel-tl .x-panel-header{
	text-align: left;
}
body {
	margin: 0px;
	background:#3fabd9 url(resources/images/layout/body-bg.gif);
	font-family:Tahoma;
	/*	background-repeat:no-repeat; */
}
h1 {
	font-size:14px;
	font-weight:bold;
	margin-bottom:5px;
	text-align:right;
	color:#666;
}

</style>	
</head>
<body>
<div style=" height:100px; background:url('resources/images/login-company-bkg.png') repeat-x; border-top:1px solid #999; border-bottom:1px solid #999" align="center"></div>
<div style="padding:50px; background:#FFF" align="center">
		<div style="width:500px;"><h1>Welcome to <?=$this->config->item("app_name")?> </h1></div>
		<div style="width:500px;">
				<div id="f-login" align="left"></div>
		</div>
		<script type="text/javascript">
		Ext.onReady(function(){
		
		    Ext.QuickTips.init();
		
		    // turn on validation errors beside the field globally
		    Ext.form.Field.prototype.msgTarget = 'qtip';
			
			var w_CT;
			var w_TU;
			var fp_admin_contact;

			htmlEditor = new Ext.form.HtmlEditor({
				id				:'id-mesaj',	
				allowBlank		:false,
				blankText		:'Reguli validare <br /><i>Camp obligatoriu</i>', 												
	            hideLabel		:true,
	            name			:'message',
	            anchor			:'100% -100',
		        enableColors	:false,
		        enableAlignments:false,
				enableFont		:false,
				enableFontSize	:false,
				enableLinks		:false,
				enableSourceEdit:false,
				fontFamilies	:['Tahoma'],
				autoMonitorDesignMode:false,
				validateValue	: function(){
					 if (this.getValue() !== ''){
		                 this.clearInvalid();
		                 return true; 																						 	
					 } else {
		                 this.markInvalid(this.blankText);
		                 return false;																						 	
					 }
				}																					
			});	
		
		    var fs = new Ext.FormPanel({
		        labelWidth: 40,
				monitorValid:true,
				renderTo:'f-login',
		        frame:true,
		        title: 'Login',
		        bodyStyle:'padding:5px 5px 5px 5px',
		        width: 500,
				labelAlign:'top',
		        items: [{
			           		layout	:'column',
			            	border	:false,
				           	items	:[{
				                	columnWidth	:.5,
				                	layout		:'form',
									defaultType	:'textfield',				
				                	border		:false,
									items		:[{
						                fieldLabel: 'Username',
						                name: 'user',
						                allowBlank:false,
										blankText	:'Reguli validare <br /><i>Camp obligatoriu</i>', 
										anchor	:'90%'
						            }]
							},{
				                	columnWidth	:.5,
				                	layout		:'form',
									defaultType	:'textfield',				
				                	border		:false,
									items		:[{
						                fieldLabel: 'Password',
						                name: 'pass',
										inputType: 'password',
										allowBlank:false,
										blankText	:'Reguli validare <br /><i>Camp obligatoriu</i>', 
										anchor	:'90%'
						            }]
							}]		
				}],
				buttons:[{
			        text: 'Submit',
					formBind:true,
			        handler: function(){
						if (fs.getForm().isValid()) {
							fs.getForm().submit({
								url: 'welcome/login/' + Math.random(),
								waitMsg: 'Verify data...',
								success: function(form, action, o){
									if (action.result.code == 0) {
										Ext.Msg.alert('Warning!', 'Utilizator sau parola incorecte!');
										fs.getForm().reset();
									}
									else 
										if (action.result.code == 1) {
											window.location = "welcome/home";
										}
								},
								failure: function(form, action){
									if (action.failureType == 'server') {
										obj = Ext.util.JSON.decode(action.response.responseText);
										Ext.Msg.alert('Warning', 'Cannot login in!', obj.errors.reason);
									}
									else {
										Ext.Msg.alert('Warning!', 'Authentication server is unreachable!');
									}
									fs.getForm().reset();
								}
							});
						}
			        }					
				},{
					text: 'Reset', 
					handler: function() {
						fs.getForm().reset(); 
					}					
				}]
			});

			if(Ext.form.VTypes){
			   Ext.apply(Ext.form.VTypes, {
			      emailText:'Reguli validare <br /><i>Camp obligatoriu. Ex. nume@domeniu.ro</i>'
			   });
			}
			
		    fp_admin_contact = new Ext.form.FormPanel({
				monitorValid:true,
				id:'frm-admin-contact-' + Math.random(),
				monitorValid:true,
		        baseCls: 'x-plain',
		        labelWidth: 75,
		        defaultType: 'textfield',
		        items: [{
		            fieldLabel: 'Nume',
		            name: 'name',
		            anchor: '100%',
					allowBlank:false,
					blankText	:'Reguli validare <br /><i>Camp obligatoriu</i>'  
		        },{
		            fieldLabel: 'Email',
		            name: 'from',
		            anchor:'100%',
					allowBlank:false,
					blankText	:'Reguli validare <br /><i>Camp obligatoriu</i>', 
					vtype:'email'
		        },{
		            fieldLabel: 'Subiect',
		            name: 'subject',
		            anchor: '100%',
					allowBlank:false,
					blankText	:'Reguli validare <br /><i>Camp obligatoriu</i>'  
		        },new Ext.form.ComboBox({
					fieldLabel:'Tip mesaj',
					name:'type',		
			        store: new Ext.data.SimpleStore({
						fields: ['value', 'option'],
						data : [
							['sesizare', 			'Sesizare defect'], 
							['functionalitate', 	'Cerere functionalitate']
						]
					}),
					displayField: 'option',
					valueField: 'value',
			        mode: 'local',
					triggerAction: 'all',
			        emptyText:'[ Selectati ]',
			        selectOnFocus:true,
					forceSelection:true,
					editable:false,
					allowBlank:false,
					blankText	:'Reguli validare <br /><i>Camp obligatoriu</i>'  
			    }),htmlEditor],
				buttons:[{
					text		:'Send',
					tooltip		:'Trimiteti',
					formBind	:true,
					handler		:function(){
						if(fp_admin_contact.getForm().isValid()){
							fp_admin_contact.getForm().submit({
								url: "admin/contact/" + Math.random(),
								waitTitle: 'Connecting',
								waitMsg: 'Validating and saving data...',
								success: function(form, action, o) {
									if (action.result.code == 1) {	
											Ext.MessageBox.alert('Mesaj:', 'Trimitere mail efectuata cu succes!');
											fp_admin_contact.getForm().reset();
											w_CT.hide();
									}else if (action.result.code == 0){
											Ext.MessageBox.alert('Eroare:', response.responseText);														
									}
								},										
								failure: function(form, action, o){
								            if(action.failureType == 'server'){
								                Ext.Msg.alert('Warning', 'Trimitere mail esuata!', obj.errors.reason);
								            }else{
								                Ext.Msg.alert('Warning!', 'Authentication server is unreachable!');
								            }
								}
							})
						}
					}
					},{
						text		:'Reset',
						tooltip		:'Resetati',
						handler		:function(){
							fp_admin_contact.getForm().reset();
						}	
					}
				]					
		    });
	
			Ext.get('CT').on('click', function(){
				if (!w_CT) {
					w_CT = new Ext.Window({
						title:'Contact',
						id: 'w_admin_contact' + Math.random(),
						width: 600,
						height: 400,
						modal:true,
				        plain:true,
						layout:'fit',
						closable:true,
						closeAction:'hide',						
				        bodyStyle:'padding:5px;',
				        buttonAlign:'center',						
						items: fp_admin_contact,
						listeners:{
							show:function(){	
								fp_admin_contact.getForm().reset();
							}
						}										
					});
				} else {}
				w_CT.show(null, htmlEditor.checkDesignMode, htmlEditor);	
			});
			
			Ext.get('TU').on('click', function(){
				if (!w_TU) {
					w_TU = new Ext.Window({
						title:'Terms of use',
						id: 'w-terms' + Math.random(),
						width: 600,
						height: 400,
						modal:true,
						layout:'fit',
						closable:true,
						closeAction:'hide',
						defaultType: 'iframepanel',
		                items:{ 
							loadMask:{hideOnReady :true,msg:'Loading ...'},
							frameConfig	:{
								id:'termsIframe'
							}	                    
						},
						listeners:{
							show:function(){	
								Ext.get('termsIframe').load({
									url: 'admin/terms/' + Math.random()								
								});
							}
						}
					});
				} else {}
				w_TU.show();	
			});	
								
		});	
		
		</script>			
		<!-- <div style=" text-align:right; width:349px; height:29px; background:url(resources/images/layout/login-app-name.png); margin-top:3px;">
			 <span style="color:#336699; font-family:Tahoma; font-size:11px; padding:4px;">developed by iello-dev[internet hello] <br />version: <?=$this->config->item('app_version')?></span> 
		</div> -->
</div>
<div style=" height:30px; padding:3px; background:#e8e8e8; border-top:1px solid #999" align="center">
	<div style="width:500px; padding-top:12px;">
		<div style="width:49%; float:left" align="left"><span style="color:#336699; font-family:Tahoma; font-size:11px; padding:4px;">version: <?=$this->config->item('app_version')?></span> </div>
		<div style="width:49%; float:right" align="right"><span style="color:#336699; font-family:Tahoma; font-size:11px; padding:4px;"><div id="TU" style="float:right; cursor:pointer;">&nbsp; Terms of use | </div><div id="CT"style="float:right; cursor:pointer;">&nbsp;Contact | </div></span> </div>
	</div>
</div>
</body>
</html>

